<html>
    <head>
        <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
        <title>接口列表</title>

        <style>
            body{ margin: 0; padding: 0; font-size:16px}
            body,html{-webkit-text-size-adjust: none;width: 100%;height: 100%;}
            *{text-decoration: none;list-style: none;}
            a:link {color: #000; text-decoration: none;}
            a:visited {text-decoration: none; color: #000;}
            a:hover {text-decoration: underline;color: #000;}
            a:active {text-decoration: none;}
            img{border: 0px;}
            table,table tr th, table tr td { border:1px solid #000000; }
            table{background: #cccccc; min-height: 25px; line-height: 25px; text-align: center; border-collapse: collapse;}
            .raw_body {font-style: italic;}
            #content{ width: 90%; margin-left: 5%}
            div.res_data{ max-width: 100%; overflow-x: auto; }
            div.api {clear: both; margin-bottom:50px}
            pre {padding: 10px}
            .bg { background: #cccccc; margin: 0; border-radius: 10px }
            .panel { width: 100%; margin-bottom:5px}
            li {margin:5px 50px}
        </style>
    </head>
    <body>
    <div id="content">
        <a name='api_0'></a>
        <div class='api panel'>
            <span class='title'>错误码</span>
            <div class="panel bg">
            <pre>{% for err_code in err_codes %}
    {{ err_code.tag }} = {{ err_code.code }}; // {{ err_code.message }}{% endfor %}</pre>
            </div>
        </div>
        <div class='api panel'>
            <span class='title'>返回格式</span>
            <div class="panel res_data bg">
            <pre>{{ ret_sample_data | to_json(indent=4, ensure_ascii=False) }}</pre>
            </div>
        </div>
        <div class='api panel'>
            <span class='title'>接口列表</span>
            <div class="panel">
            {% for api in api_list %}
                <li><a href='#api_{{ loop.index }}'>{{ api.name }}</a></li>
            {% endfor %}
            </div>
        </div>
        {% for api in api_list %}
        <div class='api panel'>
            <a name='api_{{ loop.index }}'></a>
            <h3>{{ api.name }}</h3>
            <span class='title'>请求地址</span>
            <div class="panel bg">
                <pre>{{ api.path }}</pre>
            </div>
            <span class='title'>支持请求类型</span>
            <div class="panel bg">
                <pre>{{ api.support_methods | join(' ') }}</pre>
            </div>
            {% if api.field_info %}
            <span class='title'>参数列表</span>
            <table class="params panel">
                <tr><th>参数</th><th>名称</th><th>类型</th><th>是否必填</th><th>默认值</th><th>说明</th><th>限制</th></tr>
                {% for name, info in api.field_info.items() %}
                <tr>
                    <td class='{% if info.raw_body %}raw_body{% endif %} {% if info.required %}required{% endif %}'>
                        {% if info.required %}
                            *{{ name }}*
                        {% else %}
                            [{{ name }}]
                        {% endif %}
                    </td>
                    {% for key in ('description', 'type', 'required', 'default', 'help_text', 'ex_info') %}
                    <td>{{ info.get(key, '') }}</td>
                    {% endfor %}
                </tr>
                {% endfor %}
            </table>
            {% endif %}
            {% if api.return_sample %}
            <div class='api panel'>
                <span class='title'>返回格式说明</span>
                <div class="panel res_data bg">
                    <pre>{{ api.return_sample | to_json(indent=4, ensure_ascii=False) }}</pre>
                </div>
            </div>
            {% endif %}
        </div>
        {% endfor %}
        </div>
    </body>
</html>
